<!--我发起--策略设置-->
<template>
  <div class="bg bg1">
    <scroller class="scroller">
      <div class="wrapper" v-if="follwMap">
        <!--信息-->
        <FollwSetInfo ref="info" :followName="followName" :marks="marks" :showLine="false"></FollwSetInfo>
      </div>
    </scroller>

    <!--启动-->
    <div class="ok bg3">
      <div class="ok-but bg4" @click="cancelClick">
        <text class="font32 text1">{{T('取消')}}</text>
      </div>
      <div class="ok-but main1" @click="okClick">
        <text class="font32 text1">{{T('确认')}}</text>
      </div>
    </div>
  </div>
</template>

<script>


//组件
import FollwSetInfo from '@/strategy/view/FollwSetInfo.vue' 

//功能
import navigator from "@/_js/navigator"; 
import modal from "@/_js/modal";
import broadcast from "@/_js/broadcast";

import weexHttp from "@/_js/https"; ;
const weexFunction = weex.requireModule("WeexFunction");

import I18N from "@/_i18n/i18n";
var T = I18N.t;
weexFunction.setTitle(T('跟单设置'));

export default {
  
  components: {
    FollwSetInfo,
  },

  data() {
    return {
      T:T,
      executeId:'', //执行Id
      follwMap:undefined,

      systemLimit:undefined, //服务器限制
      investLimit:undefined, //用户限制

      followName:'', //跟单名称
      marks:[], //跟单标签
    };
  },

  mounted() {

    this.executeId = navigator.getParam('executeId');
    this.httpQueryFollowDetail();
  },

  methods: {

    /********************************************** http*/
    //http查询跟单信息
    httpQueryFollowDetail(){
      
      modal.showLoad();
      var param = {'executeId':this.executeId};
      weexHttp.post("follow/queryEditFollowDetail",param,true,(data)=>{

        modal.hideLoad();
        if(data.status == 200){
          data = data.data;
          
          this.systemLimit = data.systemLimi;
          this.investLimit = data.investLimit;
          this.followName = data.followName;
          this.marks = data.mark ? data.mark : [];

          this.follwMap = data;
        } else {
          modal.toast(data.msg);
        }
      });
    },
    
    //http修改跟单信息
    httpEditFollowInfo(){
      
      modal.showLoad();
      var info = this.$refs.info.getParam();

      var param = JSON.parse(JSON.stringify(this.follwMap));
      param.followName = info.followName;
      param.mark = JSON.stringify(info.marks);

      weexHttp.postX("follow/editFollowInfo",param,true,(data)=>{
        modal.hideLoad();
        if(data.status == 200){
          modal.toast(T('修改成功'));

          // 发送消息广播，通知修改成功
          broadcast.send("MFollwStrategySet",info);

          this.cancelClick();
        } else {
          modal.toast(data.msg);
        }
      });
    },
    
    /********************************** 点击触发*/
     //取消点击
    cancelClick(){
      navigator.back();
    },

    //确定点击
    okClick(){

      if (this.$refs.info.checkError()){
        return;
      }
      this.httpEditFollowInfo();
    },
    
  }
}

</script>


<style src="@/_css/style.css"></style>
<style scoped>
.bg {
  width: 750px;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}
.scroller {
  width: 750px;
  z-index: 9;
}
.wrapper{
  width:750px;
  padding-left: 40px;
  padding-right: 40px;
}

.money{
  margin-top: 40px;
}

.switc{
  width: 670;
  margin-top: 40px;
}

/*************** 其他*/
.line{
  width: 710px;
  height: 1px;
  margin-top: 40px;
  margin-bottom: 40px;
}
.limit-tipe{
  width: 670px;
  line-height: 36px;
}
.add{
  flex-direction: row;
  justify-content: center;
  align-items: center;
  height: 88px;
  border-radius: 16px;
  padding-left: 40px;
  padding-right: 40px;
  margin-right: -40px;
  margin-left: 20px;
}
.time{
  width: 40px;
  height: 40px;
}

/*************** 输入框*/
.input{
  flex-direction: row;
  align-items: center;
  height: 88px;
  border-radius: 16px;

  border-width: 2px;
  border-color: transparent;

  margin-top: 20px;
  padding-left: 40px;
  padding-right: 40px;
}
.input-content{
  flex: 1;
  height: 88px;
  placeholder-color:#6E7488;
}
.input-line{
  width: 2px;
  height: 32px;
  margin-left: 20px;
  margin-right: 20px;
}
.width252{
  width: 252px;
}
.width380{
  width: 380px;
}
.width670{
  width: 670px;
}

/*************** 付费方式*/
.pay-menu{
  flex-direction: row;
  align-items: flex-end;
  width: 750px;
  height: 84px;
  margin-top: 40px;
  margin-left: -40px;
}
.pay-menu-line{
  height: 1px;
  border-top-width: 2px;
}
.pay-select{
  width: 24px;
  height: 24px;
  margin-right: 8px;
}
.pay-menu-but {
  flex-direction: row;
  align-items: flex-end;
  padding-left: 40px;
  padding-right: 40px;
  padding-bottom: 20;
}
.pay-menu-but-left1{
  height: 84px;
  border-top-width: 2px;
  border-right-width: 2px;
  border-top-right-radius: 8px;
}
.pay-menu-but-right1{
  height: 74px;
  border-bottom-width: 2px;
  border-top-right-radius: 8px;
  border-top-left-radius: 8px;
}
.pay-menu-but-left2{
  height: 74px;
  border-top-right-radius: 8px;
}
.pay-menu-but-right2{
  height: 84px;
  border-top-width: 2px;
  border-left-width: 2px;
  border-right-width: 2px;
  border-top-right-radius: 8px;
  border-top-left-radius: 8px;
}

/*************** 启动*/
.ok{
  flex-direction: row;
  justify-content:space-around;
  width: 750px;
  height: 164px;
  padding-left: 40px;
  padding-right: 40px;
}
.ok-but{
  flex-direction: row;
  justify-content: center;
  align-items: center;
  width: 240px;
  height: 80px;
  border-radius: 4px;
  margin-top: 28px;
}

/*************** 间距*/
.height24{
  height: 24px;
}
.height40{
  height: 40px;
}
.height60{
  height: 60px;
}
</style>